package com.licoba.emoji.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.licoba.emoji.ui.fragment.first.FirstFragment;
import com.licoba.emoji.ui.fragment.first.child.childpager.FirstPagerFragment;
import com.licoba.emoji.ui.fragment.first.child.childpager.SecondPagerFragment;

/**
 * @site www.licoba.top
 * @date 2018/10/13  10:23
 * @note
 */
public class PagerFragmentAdapter extends FragmentPagerAdapter {
    private String[] mTitles;

    public PagerFragmentAdapter(FragmentManager fm) {
        super(fm);

    }

    public PagerFragmentAdapter(FragmentManager fm, String... titles) {
        super(fm);
        mTitles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return FirstPagerFragment.newInstance();
        } else {
            return SecondPagerFragment.newInstance();
        }
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
